#include <cstring>
#include <iostream>
#include <algorithm>

using namespace std;

const int N = 9, M = 1 << N;

int ones[M], map[M];
int row[N], col[N], cell[3][3];
int arr[9][9] = {
	{0, 0, 5,  3, 0, 0,  0, 0, 0},
	{8, 0, 0,  0, 0, 0,  0, 2, 0},
	{0, 7, 0,  0, 1, 0,  5, 0, 0},

	{4, 0, 0,  0, 0, 5,  3, 0, 0},
	{0, 1, 0,  0, 7, 0,  0, 0, 6},
	{0, 0, 3,  2, 0, 0,  0, 8, 0},

	{0, 6, 0,  5, 0, 0,  0, 0, 9},
	{0, 0, 4,  0, 0, 0,  0, 3, 0},
	{0, 0, 0,  0, 0, 9,  7, 0, 0}
};

void init()
{
    for (int i = 0; i < N; i ++ )
        row[i] = col[i] = (1 << N) - 1;

    for (int i = 0; i < 3; i ++ )
        for (int j = 0; j < 3; j ++ )
            cell[i][j] = (1 << N) - 1;
}

void draw(int x, int y, int t, bool is_set)
{
    if (is_set) arr[x][y] = 1 + t;
    else arr[x][y] = 0;

    int v = 1 << t;
    if (!is_set) v = -v;

    row[x] -= v;
    col[y] -= v;
    cell[x / 3][y / 3] -= v;
}

int lowbit(int x)
{
    return x & -x;
}

int get(int x, int y)
{
    return row[x] & col[y] & cell[x / 3][y / 3];
}

bool dfs(int cnt)
{
    if (!cnt) return true;

    int minv = 10;
    int x, y;
    for (int i = 0; i < N; i ++ )
        for (int j = 0; j < N; j ++ )
            if (arr[i][j] == 0)
            {
                int state = get(i, j);
                if (ones[state] < minv)
                {
                    minv = ones[state];
                    x = i, y = j;
                }
            }

    int state = get(x, y);
    for (int i = state; i; i -= lowbit(i))
    {
        int t = map[lowbit(i)];
        draw(x, y, t, true);
        if (dfs(cnt - 1)) return true;
        draw(x, y, t, false);
    }

    return false;
}

int main()
{
    for (int i = 0; i < N; i ++ ) map[1 << i] = i;
    for (int i = 0; i < 1 << N; i ++ ){
        int s = 0 ;
        for(int j = 0; j; j -= lowbit(j))s ++ ;
        ones[i] = s;
    }
        
           

    init();

    int cnt = 0; 
    for (int i = 0; i < N; i ++ )
        for (int j = 0; j < N; j ++ )
            if (arr[i][j] != 0)
            {
                int t = arr[i][j] - 1;
                draw(i, j, t, true);
            }
            else cnt ++ ;

    if(dfs(cnt))for(int i = 0; i < N; i ++ ){
        for(int j = 0; j < N; j ++ ){
            cout << arr[i][j] << " ";
        }
        cout << endl;
    }
    
    else cout << "None";

    return 0;
}
